﻿<a color ='color'><h2><%= t :dsphattien%> </h2></a>
<p><%= t :rules%></p>
<%count = 0%>
<%@overdue = Borrowedtable.find(:all, :conditions => ['Deadline < ? AND PayedDate IS NULL',"#{Date.today}"]) %>
<%@users    = User.find(:all) %>
<% if(@overdue.count == 0) %>
<h3>Hiện Tại không có người dùng nào trễ hạn</h3>
<%else%>
<font size = '4'> 
<table border="2";> 
  <tr> 
   <th><b><%= t :sott%></b></th>
   <th><b><%= t :nguoidung%></b></th> 
   <th><b><%= t :tensach%></b></th>
   <th><b><%= t :hantrasach%></b></th>
   <th><b><%= t :songaytre%></b></th>
   <th><b><%= t :tienphat%></b></th>
   <th><b><%= t :tongtien%></b></th>
  </font>   
  </tr>
    <%@users.each do |users|%>
        <%@overover = Borrowedtable.find(:all, :conditions => ['Deadline < ? AND PayedDate IS NULL AND NameOfBorrow = ?',"#{Date.today}","#{users.firstName+users.lastName}"]) %>
        <%temp  = 0%>
        <%total = 0%>
        <%@overover.each do |overover|%>
        <%total = total + Integer(Date.today - overover.Deadline)*5000%>
        <%end%>
        <%@overover.each do |overover|%>
        <%if(temp == 0)%>    
            <tr> 
            <td rowspan = " <%=@overover.count%> "><%=count = count+1%></td> 
            <td rowspan = " <%=@overover.count%> "><%=overover.NameOfBorrow%></td> 
            <td><%=overover.NameOfDrink%></td>

            <td><%=overover.Deadline%></td>  
            <td><%=Integer(Date.today - overover.Deadline)%></td>
            <td><%=Integer(Date.today - overover.Deadline)*5000%></td>
            <td rowspan = " <%=@overover.count%> "><%=total%>
            </tr> 
            <%temp = temp + 1 %> 
       <%else%>
            <tr> 
            <td><%=overover.NameOfDrink%></td>

            <td><%=overover.Deadline%></td>
            <td><%=Integer(Date.today - overover.Deadline)%></td>
            <td><%=Integer(Date.today - overover.Deadline)*5000%></td>            
            </tr> 
            <%temp = temp + 1 %> 
    
        <%end%>
       
    <%end%>
    
   <%end%>
<%end%>
</table> 




